-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GLUTEN-7745][VL] Incorporate SQL Union operator into Velox execution pipeline #7842
Conversation
Thanks for opening a pull request! Could you open an issue for this pull request on Github Issues? https://github.com/apache/incubator-gluten/issues Then could you also rename commit message and pull request title in the following format?
See also: |
Run Gluten Clickhouse CI on x86 |
backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxMetricsApi.scala
Outdated
Show resolved
Hide resolved
0459eec
to
543b2d0
Compare
Run Gluten Clickhouse CI on x86 |
3 similar comments
Run Gluten Clickhouse CI on x86 |
Run Gluten Clickhouse CI on x86 |
Run Gluten Clickhouse CI on x86 |
ffc6b69
to
6b22f18
Compare
Run Gluten Clickhouse CI on x86 |
1 similar comment
Run Gluten Clickhouse CI on x86 |
8e32171
to
725137d
Compare
Run Gluten Clickhouse CI on x86 |
1 similar comment
Run Gluten Clickhouse CI on x86 |
68550df
to
8736e5b
Compare
Run Gluten Clickhouse CI on x86 |
Run Gluten Clickhouse CI on x86 |
Run Gluten Clickhouse CI on x86 |
Run Gluten Clickhouse CI on x86 |
Run Gluten Clickhouse CI on x86 |
Run Gluten Clickhouse CI on x86 |
Run Gluten Clickhouse CI on x86 |
Run Gluten Clickhouse CI on x86 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some minor comments.
expected = df.collect() | ||
} | ||
// By default we will fallabck complex type scan but here we should allow | ||
// By default, we will fallabck complex type scan but here we should allow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also fix typo: fallabck
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/** | ||
* run a query with native engine as well as vanilla spark then compare the result set for | ||
* correctness check | ||
*/ | ||
protected def compareResultsAgainstVanillaSpark( | ||
sqlStr: String, | ||
protected def compareDfResultsAgainstVanillaSpark( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Df
means Dataframe? The naming seems not friendly to reader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just use DF? It's a common abbreviation of DataFrame in spark. I think we'd avoid making names too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhztheplayer, I see. It's ok to firstly use your proposed name. Thanks!
} | ||
} | ||
|
||
private def sameNumPartitions(plans: Seq[SparkPlan]): Boolean = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this into the below validate
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its purpose is to make the code self-explanatory. Say reader will know we are comparing the partition numbers of children because they see sameNumPartitons
as method name.
bool validateInputTypes(const ::substrait::extensions::AdvancedExtension& extension, std::vector<TypePtr>& types); | ||
/// Used to get types from advanced extension and validate them, then convert to a Velox type that has arbitrary | ||
/// levels of nesting. | ||
bool validateInputVeloxType(const ::substrait::extensions::AdvancedExtension& extension, TypePtr& out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateInputVeloxType
makes me feel that the input is velox type. Can we use some other name, e.g., parseToVeloxType
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing to parseVeloxType
. Thanks.
Run Gluten Clickhouse CI on x86 |
// FIXME: The whole metrics system in gluten-substrait is magic. Passing metrics trees through JNI with a trivial | ||
// array is possible but requires for a solid design. Apparently we haven't had it. All the code requires complete | ||
// rework. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it's really painful to add new metrics in Gluten Velox backend. There is a set of metrics from Velox query plan being converted to a tree or an array again and again during passing to Spark Java side. A lot of magical IDs are used during the tree / array traversal algorithms with a lot of special handling of corner cases, e.g., join, filter project, and union which is added in this PR.
The whole metric system should be reworked (if someone could lead this work) otherwise it's unmaintainable.
Run Gluten Clickhouse CI on x86 |
#7745
Edit: The single-threaded execution issue will be fixed in Velox facebookincubator/velox@e80bf12.
Introduce new config
spark.gluten.sql.native.union
(by default,false
) which works for Velox backend only at the moment.Native union will not be used when children of union operator don't share the same known partition number. (perhaps can be fixed in future)
There is a Spark UT failing when enabling native union, it's related to Velox LocalParition output order and requires fixing in future:
So far the failure is benign since in SQL we don't often guarantee output ordering of union operator.
This is currently a PoC and not yet workable because of a blocker from Velox's single-threaded execution design:Related Velox code:https://github.com/facebookincubator/velox/blob/12b52e70ec85ae0cdb4aa990797cddda9be5be27/velox/exec/Driver.h#L658-L660